<?php

namespace app\modules\Admin\service;

use goodsskuModel;
use Illuminate\Database\Capsule\Manager as DB;

class Scoreshop
{
    public static function formatGoodsSku(Array $sku_arr, String $sku_text)
    {
        $result = [];
        if(count($sku_arr)){
            $sku_text_arr = explode(',', $sku_text);
            foreach ($sku_arr as $key => $value){
                $sku_pid = DB::table('goods_sku')->where('id', $value)->value('pid');
                $sku_name = goodsskuModel::query()->where('id', '=', $sku_pid)->value('name');
                $result[$key]['id'] = $value;
                $result[$key]['name'] = $sku_name;
                $result[$key]['text'] = $sku_text_arr[$key];
            }
            unset($sku_pid);
            unset($key);
            unset($value);
            unset($sku_name);
        }
        return $result;
    }
}